package variable;

/**
 * An action that can only be called a certain number of times.
 * Afterwards, calls to this action does nothing.
 * 
 * @author g1wshimu
 */
public abstract class LimitedAction {

    private int MAX_CALL;
    private int call;

    protected LimitedAction(int maxCall) {
        this.MAX_CALL = maxCall;
        this.call = 0;
    }

    protected abstract void action();

    public final void performAction() {
        if (call < this.MAX_CALL) {
            action();
            call++;
        }
    }
}
